﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserLogin.aspx.cs" Inherits="WebUI.Form.UserLogin" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
       <link rel="stylesheet" href="../BootFlat/css/site.min.css">
  
    <!--[if lt IE 9]>
      <script src="../BootFlat/js/html5shiv.js"></script>
      <script src="../BootFlat/js/respond.min.js"></script>
    <![endif]-->
    <%--<script src="../Scripts/jquery-2.2.3.js"></script>--%>
    <script src="../Scripts/jquery-1.7.1.js"></script>
    <script type="text/javascript" src="../BootFlat/js/site.min.js"></script>
        <link href="../Css/login.css" rel="stylesheet" />
    <script src="../Scripts/layer/layer.js"></script>
</head>

<body>
    <form id="form1" runat="server">
       <div id="u-login">
          
            
 <div class="col-md-6 u_textdiv">
     <ul>
     <li>用户名：</li>
         <li> <input type="text" autocomplete="on"  class="form-control u_minwidthtext" runat="server" placeholder="用户名" id="user" /></li>
       <%--  <li><span class="errormes">*必填</span></li>--%>
              </ul></div>
   
        <div class="col-md-6 u_textdiv">
            <ul>
<li>&nbsp;&nbsp;&nbsp;密码：</li>
                <li><input type="password" autocomplete="on"  class="form-control u_minwidthtext" runat="server" placeholder="密码" id="pwd" /></li> 
              </ul></div> 
              <%-- <div class="yzm">--%>
                   
   <%--                <div class="col-md-6 u_textdiv">     
                    </div> --%>

               <%--</div>--%>   
             
           
          <div class="col-md-6 u_textdiv">
              <%--<asp:Button ID="yzmbtnhiddle" runat="server" Text="验证码验证按钮 " Visible="false" OnClick="yzmbtnhiddle_Click" />--%>
            <%--<button type="button" class="btn btn-block minwidthbutton" id="loginid" runat="server" onClick="loginClick"  >管理员登录</button>--%>
             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:Button ID="loginid" runat="server" Text="用户登录"  class="btn btn-primary " OnClick="loginClick" />
               </div>
           <%--    <div class="col-md-6">
                <div class="popover left">
                  <div class="arrow"></div>
                  <h3 class="popover-title">Popover left</h3>
                  <div class="popover-content">
                    <p>Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.</p>
                  </div>
                </div>
              </div>--%>
   
 
       </div>
  
    </form>
    <script>
        function checktext() {

            if ($("#user").val() == "") {
                layer.alert('用户名不可以为空！');
                return "f";
            }
            if ($("#pwd").val() == "") {
                layer.alert('密码不可以为空！');
                return "f";
            }
            return "s";
        }


        $(function () {
            $("#loginid").click(function () {
                var geta = checktext();
                if (geta == "f") {
                    return false;
                }
                var userstr = $("#user").val();
                var pwdstr = $("#pwd").val();
                $.ajax({
                    //要用post方式   
                    type: "Post",
                    //方法所在页面和方法名   
                    url: "UserLogin.aspx/LoginUser",
                    data: JSON.stringify({ user: userstr, pwd: pwdstr }),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                      
                        //返回的数据用data.d获取内容   
                        if (data.d == "ok") {
                            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                            console.log(index);
                        parent.layer.close(index); parent.layer.load(index);
                            $.ajax({
                                //要用post方式   
                                type: "Post",
                                //方法所在页面和方法名 
                                url: "../Services/GlobalAppVariable.ashx?action=setusersession&username="+userstr,
                                //data:  JSON.stringify({ "action": "setusersession", "username": userstr }),
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (data) {
                                    //返回的数据用data.d获取内容 
                                    console.log(data);
                                    //if (data.d == "ok") {
                                    //layer.alert("ssss");
                                    layer.closeAll();
                                    window.parent.$('div').css('color', 'red');
                                   
                                        //window.location.href(data.d);
                                    //}
                                    //if (data.d == "fail") {
                                    //    layer.alert("sssaxx");
                                    //}

                                },
                                error: function (err) {
                                    layer.alert(err);
                                }
                            });
                            //window.location.href(data.d);
                        }
                        if (data.d == "用户名密码不对！") {
                            layer.alert(data.d);
                        }

                    },
                    error: function (err) {
                        layer.alert(err);
                    }
                });

                //禁用按钮的提交   
                return false;
            });
        });
    </script>

</body>
</html>
